<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>灯泡开关04</title>
    <style>
        .box{
            margin: 10px auto;
            text-align: center;
        }
        button{
            cursor: pointer;
            outline: none;
            margin-bottom: 20px;
            color: #fff;
        }
    </style>
</head>
<body>
    <div class="box">
        <button type="button">开启</button><br/>
        <img src="img/pic_bulboff.gif" alt="">
        <!-- <img src="img/pic_bulbon.gif" alt=""> -->
    </div>
</body>
    <script>
        var btn = document.querySelector('button')
        var imgs = document.querySelector('img')
        btn.onclick = function(){
            if(btn.innerHTML == '开启'){
                imgs.src = 'img/pic_bulbon.gif'
                btn.innerHTML = '关闭'
                btn.style.background = '#87eb35'
                
            }else{
                imgs.src = 'img/pic_bulboff.gif'
                btn.innerHTML = '开启'
                btn.style.background = '#eba535'
            }

        }
    </script>
</html>